import Net from 'network.js'

/**
 * 登录
 * 
 */
export const login = (jscode, callback) => {
  Net.post('/miniapp.login2', {
    jscode,
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '')
}

/**
 * 发送手机验证码 (hmily )
 */
export const smsSend = (mobile, callback) => {
  Net.post('/sms.send', {
    mobile
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '')
}

/**
 * 绑定挪车二维码 (hmily )
 * auto_no 车牌号
 * name 姓名
 * phone 手机号
 * qcode 二维码
 * verifyCode 手机验证码
 */
export const qcodeBind = (auto_no, name, phone, qcode, verifyCode, callback) => {
  Net.post('/miniapp.qcode.bind', {
    auto_no,
    name,
    phone,
    qcode,
    verifyCode
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}

/**
 * 获取解密后的信息 (hmily ) 
 * iv
 * encryptedData
 */
export const getDecryptInfo = (iv, encryptedData, callback) => {
  Net.get('/miniapp.mobile', {
    iv,
    encryptedData
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '')
}

/**
 * 获取二维码状态 (hmily ) 
 */
export const getQcodeInfo = (qcode, callback) => {
  Net.get('/miniapp.qcode.info', {
    qcode
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '')
}


/**
 * 获取用户是否有绑定了的二维码 (hmily ) 
 */
export const getIsBind = (callback) => {
  Net.get('/customer.has_qcodes', { 
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '')
}



/** 
 * 根据二维码编号获取车主手机号 (hmily )
 * qcode 二维码编号
 */
export const getVPhone = (qcode, address, callback) => {
  Net.get('/vphone.bxbind', {
    qcode,
    address
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 * 下单 (hmily )
 * id 商品ID
 */
export const payment = (callback) => {
  Net.get('/payment.miniapp.test', {

  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 * 获取天气,油价，限行等信息 (hmily ) 
 */
export const getweather = (city, prov, callback) => {
  Net.get('/query.all', {
    city,
    prov,
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}




/**
 * 推送开关
 * content 开启用1，关闭用0
 */
export const remindSwitch = (keyword, mcontent, callback) => {
  Net.post('/user.setup', {
    keyword,
    mcontent,
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '')
}




/**
 * 获取违章信息前获取车主信息 (hmily ) 
 */
export const getCarInfo = (callback) => {
  Net.get('/auto.info', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '')
}


/**
 * 获取违章信息 (hmily ) 
 */
export const getPeccancyInfo = (callback) => {
  Net.get('/auto.weizhang', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 * 设置车架号
 
 */
export const setFrameno = (frameno, callback) => {
  Net.post('/auto.detail', {
    frameno
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '')
}

// /**
//  * 获取报告信息 (hmily ) 
//  */
// export const getReportInfo = (report_id,callback) => {
//   Net.get('/report.profile', {
//     report_id
//   }, (r) => {
//     callback(r);
//   }, (e) => { console.log(e) }, {}, true, '加载中...')
// }




/**
 * 获取用户是否绑定过挪车码 (hmily ) 
 */
export const getUserStatus = (callback) => {
  Net.get('/miniapp.userinfo', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 * 获取优惠券列表 (hmily ) 
 */
export const getCoupons = (callback) => {
  Net.get('/customer.coupons', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}

/**
 * 获取会员卡列表 (hmily ) 
 */
export const getCards = (callback) => {
  Net.get('/customer.paid_packages', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}



/**
 * 获取消费纪录 (hmily ) 
 */
export const getRecords = (orderState, callback) => {
  Net.get('/customer.service_records', {
    orderState
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}



/**
 * 获取消费纪录详情 (hmily ) 
 */
export const getRecordDetail = (id, callback) => {
  Net.get('/customer.service_record', {
    id
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}




/**
 * 获取评论初始配置 (hmily ) 
 */
export const evaluateInit = (merchant_id, callback) => {
  Net.get('/customer.rating_options', {
    merchant_id
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 * 提交评论 (hmily ) 
 */
export const submitEvaluate = (merchant_id, comment, service_record_id, data, callback) => {
  Net.post('/customer.rating', {
    merchant_id,
    comment,
    service_record_id,
    data
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '提交中...')
}

/**
 * 获取违章车辆列表 (hmily ) 
 */
export const weizhangcarlist = (callback) => {
  Net.get('/customer.traffic_cars', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}



/**
 * 违章查询添加车辆
 
 */
export const addCar = (auto_number, CarVin, EngineNo, callback) => {
  Net.post('/customer.traffic_car', {
    auto_number,
    CarVin,
    EngineNo
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '添加中...')
}

/**
 * 查询违章车辆 (hmily ) 
 */
export const searchWeiZhang = (auto_number, callback) => {
  Net.get('/customer.weizhang', {
    auto_number
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}

/**
 * 申请挪车码轮播图 (hmily ) 
 */
export const getApplySwiper = (callback) => {
  Net.get('/customer.applyqcode', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 * 申请挪车码轮播图 (hmily ) 
 */
export const getShops = (latlng, callback) => {
  Net.get('/customer.applyqcode.shopopt', {
    latlng
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}



/**
 * 立即领取u车码
 
 */
export const applySubmit = (mobile, verifyCode, merchant_id, callback) => {
  Net.post('/customer.applyqcode', {
    mobile,
    verifyCode,
    merchant_id,
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '申请中...')
}


/**
 * 立即领取u车码
 
 */
export const wxNuoChe = (qcode, address, callback) => {
  Net.post('/customer.nuoche', {
    qcode,
    address
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '发送中...')
}


/**
 * 获取用户的会员卡列表 (hmily ) 
 */
export const getUserPackages = (callback) => {
  Net.get('/customer.card_packages', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}



/**
 * 查看套餐信息 (hmily ) 
 */
export const getPackageDetailById = (id, callback) => {
  Net.get(id, '/customer.package_card', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 * 用户收到商户推送的 会员卡办理页 (hmily ) 
 */
export const userHandlePackage = (id, mtype, callback) => {
  Net.get('/customer.package_and_card', {

    id,
    mtype,
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 *  客户办理套餐 消费等 (hmily ) 
 */
export const userPayment = (body, mtype, id, callback) => {
  Net.get('/payment.uni_pay', {
    body,
    mtype,
    id,
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 *   检测记录列表 (hmily ) 
 */
export const getCheckListInfo = (callback) => {
  Net.get('/customer.reports', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 *   用户个人中心 (hmily ) 
 */
export const getUserInfo = (callback) => {
  Net.get('/customer.center', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}



/**
 *   获取报告详情 (hmily ) 
 */
export const getReportInfo = (report_id, callback) => {
  Net.get('/merchant.report.show', {
    report_id
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 *   获取挪车信息 (hmily ) 
 */
export const getNuoCheInfo = (callback) => {
  Net.get('/user.setup.nuoche', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}


/**
 *   设置挪车信息 (hmily ) 
 */
export const setNuoCheInfo = (nuoche_phone,nuoche_enabled, callback) => {
  Net.post('/user.setup.nuoche', {
    nuoche_phone,
    nuoche_enabled
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '修改中...')
}

/**
 *   获取u车匠介绍信息 (hmily ) 
 */
export const getAbout = (callback) => {
  Net.get('/customer.searchresult', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}

/**
 *   创建洗车分享 (hmily ) 
 */
export const createShare = (created_from, callback) => {
  Net.post('/customer.clean_car', {
    created_from
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, false, '')
}


/**
 *   获取u车匠关于我们信息 (hmily ) 
 */
export const getAboutUs = (callback) => {
  Net.get('/customer.center.about_us', {}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
}

/**
 *   获取帮助洗车的人员信息 (hmily ) 
 */
export const getHelpUserInfo = (ppid,callback) => {
  Net.get('/customer.help_clean_car', { ppid}, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
} 


/**
 *   帮助洗车 (hmily ) 
 */
export const helpXiChe = (ppid, callback) => {
  Net.post('/customer.help_clean_car', { ppid }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '加载中...')
} 

/** 
 * 新用户帮助洗车提交手机号 (hmily )  
 */
export const newUserSubmit = (phone, callback) => {
  Net.post('/customer.store_phone', {
    phone
  }, (r) => {
    callback(r);
  }, (e) => {
    console.log(e)
  }, {}, true, '')
}   